#include <string>

#include "element.h"

using namespace std;

Element::Element (string aName, BaseSubElement* aSub) : BaseElement(aName), sub (aSub) {
}

Element::~Element () {
}

bool Element::isParentOf (BaseElement & be) {
	//TODO
}

std::string Element::generateRegex(DoctypeDefinition* dtd) {

	// TODO handle the case where there is no children for this node
	// according to the sub regex
	// <blahblah />
	// TODO handle namespaces
	string tag = "<" + name + "[:alnum=\"]*>";
	tag += sub->generateRegex(dtd);
	tag += "</" + name + ">";
	
	return tag;
}

void Element::print(ostream& out) {
	out << "<!ELEMENT " << name << " ";
	sub->print(out);
	out << ">\n";
	printAttributes(out);
}
